import request from "@/request/request.ts";

enum Enum {
  fetchPermissions = "/admin/acl/permission",
  addPermissions = "/admin/acl/permission/save",
  updatePermissions = "/admin/acl/permission/update",
  deletePermissions="/admin/acl/permission/remove"
}

/* 获取菜单接口 */
export const fetchPermissionsAPI = () => {
  return request({
    url: Enum.fetchPermissions,
    method: "GET",
  });
};

/* 添加或者修改菜单的接口 */
export const addOrUpdatePermissionAPI = (data:any) => {
  if (!data.id) {
    return request({
      url: Enum.addPermissions,
      method: "POST",
      data
    });
  } else {
    return request({
      url: Enum.updatePermissions,
      method: "PUT",
      data

    });
  }
};

/* 删除菜单的接口 */
export const  deletePermissionsAPI = (id:any) => {
  return request({
    url:`${Enum.deletePermissions}/${id}`,
    method: "DELETE",
  })
}
